package com.qiqi.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.qiqi.dao.CatalogMapper;
import com.qiqi.dao.FeeMapper;
import com.qiqi.dao.PhoneNumberMapper;
import com.qiqi.domain.PhoneNumber;
import com.qiqi.service.fee.FeeService;
import com.qiqi.web.vo.CatalogAndFee;

@Controller
public class ProdcutController {
	@Autowired
	private PhoneNumberMapper phoneNumberMapper;
	@Autowired
	private CatalogMapper catalogMapper;
	@Autowired
	private FeeMapper feeMapper;
	@Autowired
	private FeeService feeService;
	/**
	 * 根据产品ID获得产品信息页面
	 * @param id
	 * @return
	 */
	@RequestMapping("/product/{id}")
	public String getProduct(@PathVariable Integer id,ModelMap map){
		PhoneNumber number = phoneNumberMapper.selectByPrimaryKey(id);
		map.put("number", number);
		List<CatalogAndFee> cfs = feeService.getAllFees();
		map.put("cfs", cfs);
		return "product/detail";
	}
	/*@RequestMapping("/product/getCatalogs")
	@ResponseBody
	public List<Catalog> findCatalogs(){
		CatalogExample query = new CatalogExample();
		List<Catalog> catalogs=catalogMapper.selectByExample(query);
		return catalogs;
	}
	@RequestMapping("/product/getFees/{id}")
	@ResponseBody
	public List<Fee> findFeeByCatalog(@PathVariable int cid){
		FeeExample query = new FeeExample();
		query.createCriteria().andCidEqualTo(cid);
		List<Fee> fees=feeMapper.selectByExample(query);
		return fees;
	}*/
}
